﻿using LoadIn.Maps.Bing.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Environment.Extensions;
using Orchard.Localization;

namespace LoadIn.Maps.Bing.Handlers
{
    [OrchardFeature("LoadIn.Maps.Bing")]
    public class BingMapsSettingsPartHandler : ContentHandler
    {
        public Localizer T { get; set; }

        public BingMapsSettingsPartHandler(IRepository<BingMapsSettingsPartRecord> repository)
        {
            T = NullLocalizer.Instance;
            Filters.Add(StorageFilter.For(repository));
            Filters.Add(new ActivatingFilter<BingMapsSettingsPart>("Site"));
        }

        protected override void GetItemMetadata(GetContentItemMetadataContext context)
        {
            if (context.ContentItem.ContentType != "Site")
                return;
            base.GetItemMetadata(context);
            context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("BingMaps")));
        }
    }
}